class TradeInfo(object):
    def __init__(self, goods):
        self.total = 0
        self.trades = []
        self.__parse(goods)

    def __parse(self, goods):
        self.total = len(goods)
        self.trades = [self.__map_to_trade(i) for i in goods]

    def __map_to_trade(self, single):
        return dict(
            user_name=single.user.nickname,
            time=single.create_time or '未知',
            id=single.id # 礼物主键(根据主键可以获取到赠送者,赠送的书籍)
        )